<?php
/* 
 * @author Jens Beyer
 * @date 04-06-2012
 */
class Model implements MVC {
    /**
     *
     * @var MVC[]
     */
    protected $_mvcActionArray;

    public function action()
    {
    }

    public function view()
    {
    }

    /**
     *
     * @param MVC $mvc
     */
    public function addMVC(MVC $mvc)
    {
        $class_name = get_class($mvc);
        $this->_mvcActionArray[$class_name] = $mvc;
    }

    public function processMVC()
    {
        if(!empty($this->_mvcActionArray)) {
            ob_start();
            print_r('$this->_mvcActionArray = ');
            print_r($this->_mvcActionArray);
            print_r("\n");
            $text = ob_get_clean();
            error_log($text);
            foreach ($this->_mvcActionArray as $mvc) {
                $mvc->processAction($mvc);
                $mvc->processView($mvc);
            }
        }
    }

    /**
     *
     * @param MVC $mvc
     */
    public function processAction(MVC $mvc)
    {
        $mvc->action();
    }

    /**
     *
     * @param MVC $mvc 
     */
    public function processView(MVC $mvc) {
        $mvc->view();
    }
}